var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    }; var a;
Object.defineProperty(o, "__esModule", { value: !0 }),
    (o.EShakeType = void 0),
    (function (e) {
        (e[(e.fromStrongToWeak = 1)] = "fromStrongToWeak"), (e[(e.Strong = 2)] = "Strong");
    })((a = o.EShakeType || (o.EShakeType = {})));
var n = (function () {
    function e() { }
    return (
        (e.setSpriteState = function (e, t) {
            void 0 === t && (t = !1), e && cc.isValid(e) && e._sgNode.setState(t ? 1 : 0);
        }),
        (e.shakeScreen = function (e, t, o, n, i) {
            void 0 === t && (t = cc.v2(15, 15)), void 0 === o && (o = 0.8), void 0 === n && (n = a.fromStrongToWeak);
            for (var r = [], s = 0; s < e.children.length; ++s) {
                var l = e.children[s];
                -1 == i.indexOf(l) && r.push({ node: l, originPos: l.position });
            }
            function _(e, t) {
                for (var o = 0; o < r.length; ++o)
                    cc.isValid(r[o].node) && r[o].node.setPosition(r[o].originPos.x + e, r[o].originPos.y + t);
            }
            var c = 0,
                d = function (i) {
                    var r = (c += i) / o,
                        s = r;
                    r > 1 && (r = 1), n == a.fromStrongToWeak ? (s = 1 - r) : n == a.Strong && (s = 1);
                    var l = 2 * (Math.random() - 0.5) * t.x * s,
                        h = 2 * (Math.random() - 0.5) * t.y * s;
                    1 == r ? (cc.director.getScheduler().unschedule(d, e), _(0, 0)) : cc.isValid(e) && _(l, h);
                };
            cc.director.getScheduler().schedule(d, e, 0);
        }),
        (e.scaleLoop = function (e, t, o, a, n, i) {
            var r = cc.repeatForever(
                cc.sequence(
                    cc.scaleTo(a, t).easing(cc.easeOut(1)),
                    cc.scaleTo(a, 1).easing(cc.easeIn(1)),
                    cc.scaleTo(n, o).easing(cc.easeOut(1)),
                    cc.scaleTo(n, 1).easing(cc.easeIn(1))
                )
            ),
                s = cc.sequence(
                    cc.delayTime(i),
                    cc.callFunc(function () {
                        e.stopAction(r), (e.scale = 1);
                    })
                );
            e.runAction(r), e.runAction(s);
        }),
        (e.playLabelRoll = function (e, t, o, a, n, i, r, s, l) {
            void 0 === l && (l = !1);
            var _ = 0;
            if (!l) {
                var c = Math.ceil((i * n) / (a - o + 1));
                n = (c * (a - o + 1) + (t - o)) / i;
            }
            var d = function (l) {
                if ((_ += l) >= n)
                    return (e.string = r ? r + t.toString() : t.toString()), this.unschedule(d), void s();
                var c = Math.floor(((i * _) % (a - o + 1)) + o);
                e.string = r ? r + c.toString() : c.toString();
            };
            e.schedule(d, 0);
        }),
        e
    );
})();
o.default = n;
